<template>
  <el-dialog v-dialogDrag v-if="popenevTVisible" title="引入文件" :close-on-click-modal="false" :before-close="handleCancel" :visible.sync="popenevTVisible" width="900px">
    <DocumentPaperList ref="DocumentPaperList"></DocumentPaperList>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handleOk">确定</el-button>
      <el-button @click="handleCancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import DocumentPaperList from "../DocumentPaperList.vue"
export default {
  components: { DocumentPaperList },
  data() {
    return {
      //是否显示弹窗
      popenevTVisible: true,
      //promise 状态
      promiseStatus: null,
    };
  },
  methods: {
    showModal(data) {
      this.$nextTick(() => {
        // 获取附件数据
        this.$refs.DocumentPaperList.getTableData(data);
      })
      // 创建promise
      return new Promise((resolve, reject) => {
        this.promiseStatus = {
          resolve,
          reject,
        };
      });
    },
    handleOk() {
      //清空勾选项
      this.promiseStatus.resolve({
        choiceData: this.$refs.DocumentPaperList.records
      });
      this.destroyElement();
    },
    handleCancel() {
      //清空勾选项
      this.promiseStatus.reject({
        msg: "取消",
      });
      this.destroyElement();
    },
    /**
     * cs 2022-4-8
     * 销毁组件
     */
    destroyElement() {
      this.popenevTVisible = false;
    },
  },
};
</script>